package tgc.edu.tgq.bootstrap.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import tgc.edu.tgq.bootstrap.entity.Course;
import tgc.edu.tgq.bootstrap.entity.Grade;
import tgc.edu.tgq.bootstrap.entity.Student;
import tgc.edu.tgq.bootstrap.entity.SysUser;
import tgc.edu.tgq.bootstrap.security.UserUtils;
import tgc.edu.tgq.bootstrap.service.GradeService;
import tgc.edu.tgq.bootstrap.service.StudentService;
import tgc.edu.tgq.bootstrap.service.TbClassService;

@Controller
@RequestMapping(value = "/studentall")
public class StudentAllController {
	@Autowired
	private GradeService gradeService;
	@Autowired
	private TbClassService tbclassService;
	@Autowired
	private UserUtils userUtils;
	@Autowired
	private StudentService studentService;

		//----------个人成绩查询-------------
		@RequestMapping(value = "/self")
		public String self(ModelMap modelMap) {
			SysUser user=userUtils.getUser();
			Integer id=user.getId();
			List<Grade> list=gradeService.findByStudentId(id);
			modelMap.put("list", list);
			return "grade/self";
		}
		//---------班级成绩查询----------------
		@RequestMapping(value = "/grbjcjcx")
		public String grbjcjcx(ModelMap modelMap) {
			SysUser user=userUtils.getUser();
			Integer id=user.getId();
			Student student=studentService.findById(id);
			Integer bjId=student.getTbClass().getId();
			List<Course> courses=gradeService.findCourseByTbClassId(bjId);
			List<List<Object>> cjb= gradeService.getCjb(bjId,courses);
			modelMap.put("kcs", courses);
			modelMap.put("cjb", cjb);
			modelMap.put("stu", student);
			return "grade/grbjcjcx";
		}
}

